home *** CD-ROM | disk | FTP | other *** search
/ Champak 122 / Vol 122.iso / games / need_for.swf / scripts / frame_12 / DoAction.as
Encoding:
Text File  |  2011-01-06  |  12.4 KB  |  546 lines

  1. function firecarfun()
  2. {
  3.    if(!pauseflag)
  4.    {
  5.       Shot1_Sound.start();
  6.       this.gun.play();
  7.    }
  8. }
  9. function loadcars()
  10. {
  11.    this.frm = Math.round(Math.random() * 9);
  12.    if(this.frm == 0)
  13.    {
  14.       this.frm = 9;
  15.    }
  16.    this.gotoAndStop(this.frm);
  17.    if(this._name == "cars0")
  18.    {
  19.       this._yscale = -100;
  20.       xx = 1;
  21.       this.speedcars = Math.random() * 5 + 2;
  22.       this._y = -25 - Math.random() * 375 * 5;
  23.    }
  24.    else
  25.    {
  26.       this._yscale = 100;
  27.       this._y = -25 - Math.random() * 375 * 2;
  28.       this.upflag = this._y;
  29.       this.speedcars = Math.random() * 10 + 5;
  30.       if(this._name == "cars1")
  31.       {
  32.          xx = 2;
  33.       }
  34.       if(this._name == "cars2")
  35.       {
  36.          xx = 3;
  37.       }
  38.    }
  39.    this._x = 140 + 70 * xx;
  40.    this.onEnterFrame = this._parent.movecars;
  41.    this.onMouseDown = this._parent.onlinefire;
  42. }
  43. function movecars()
  44. {
  45.    if(_root._currentframe > 17 || _root._currentframe < 12)
  46.    {
  47.       removeMovieClip(this);
  48.    }
  49.    if(this._y < this.upflag - 200)
  50.    {
  51.       this.onLoad();
  52.    }
  53.    if(!pauseflag)
  54.    {
  55.       if(this._y > 0)
  56.       {
  57.          this.upflag = 0;
  58.       }
  59.       if(this._yscale > 0)
  60.       {
  61.          this._y += speed - this.speedcars;
  62.       }
  63.       else
  64.       {
  65.          this._y += speed + this.speedcars;
  66.       }
  67.       if(this._y > 800)
  68.       {
  69.          this.onLoad();
  70.       }
  71.       if(this.hitTest(car.hit) && !trydead)
  72.       {
  73.          trydead = true;
  74.          var _loc3_ = _root.getNextHighestDepth();
  75.          _root.attachMovie("expl","expl" + String(_loc3_),_loc3_,{_x:this._x,_y:this._y});
  76.          this._y = 1000;
  77.       }
  78.    }
  79. }
  80. function loadobstacles()
  81. {
  82.    this.frm = Math.round(Math.random() * 9);
  83.    if(this.frm == 0)
  84.    {
  85.       this.frm = 9;
  86.    }
  87.    this.gotoAndStop(this.frm);
  88.    if(this.frm < 4)
  89.    {
  90.       xx = Math.round(Math.random() * 3);
  91.       if(xx == 0)
  92.       {
  93.          xx = 3;
  94.       }
  95.       this._x = 140 + 70 * xx;
  96.       this._y = -25 - Math.random() * 375 * 1;
  97.    }
  98.    else
  99.    {
  100.       xx = Math.round(Math.random() * 6);
  101.       if(xx == 0)
  102.       {
  103.          xx = 6;
  104.       }
  105.       this._x = 160 + 35 * xx;
  106.       this._y = -25 - Math.random() * 375 * 3;
  107.    }
  108.    this.onEnterFrame = this._parent.moveobstacles;
  109.    this.onMouseDown = this._parent.onobstacleslinefire;
  110. }
  111. function onobstacleslinefire()
  112. {
  113.    if(!pauseflag)
  114.    {
  115.       if(firecar > 0 && !fire && this._y > 0)
  116.       {
  117.          var _loc3_ = this._currentframe;
  118.          if(_loc3_ == 2 || _loc3_ == 8)
  119.          {
  120.             if(this._x > car._x - 20 && this._x < car._x + 20)
  121.             {
  122.                fire = true;
  123.                var _loc4_ = _root.getNextHighestDepth();
  124.                var _loc5_ = _root.attachMovie("expl","expl" + String(_loc4_),_loc4_,{_x:this._x,_y:this._y});
  125.                _loc5_.onEnterFrame = _root.moveobject;
  126.                this.onLoad();
  127.             }
  128.          }
  129.       }
  130.    }
  131. }
  132. function moveobstacles()
  133. {
  134.    if(_root._currentframe > 17 || _root._currentframe < 12)
  135.    {
  136.       removeMovieClip(this);
  137.    }
  138.    if(!pauseflag)
  139.    {
  140.       this._y += speed;
  141.       if(this._y > 380)
  142.       {
  143.          this.onLoad();
  144.       }
  145.       if(this.hitTest(car.hit) && !trydead)
  146.       {
  147.          switch(this._currentframe)
  148.          {
  149.             case 1:
  150.             case 9:
  151.                water_Sound.start();
  152.                undrive = 1;
  153.                break;
  154.             case 2:
  155.             case 8:
  156.                car_expl_Sound.start();
  157.                if(speed > 15)
  158.                {
  159.                   trydead = true;
  160.                }
  161.                else
  162.                {
  163.                   speedverylow = 12;
  164.                }
  165.                var _loc3_ = _root.getNextHighestDepth();
  166.                _root.attachMovie("expl","expl" + String(_loc3_),_loc3_,{_x:this._x,_y:this._y});
  167.                this._y = 400;
  168.                break;
  169.             case 3:
  170.                stopdrive = 120;
  171.                break;
  172.             case 4:
  173.             case 7:
  174.                speedlow = 12;
  175.                break;
  176.             case 5:
  177.                rabbit_Sound.start();
  178.                score -= 100;
  179.                if(score < 0)
  180.                {
  181.                   score = 0;
  182.                }
  183.                this._y = 400;
  184.                break;
  185.             case 6:
  186.                stone_Sound.start();
  187.                speedverylow = 12;
  188.          }
  189.          this.onEnterFrame = _root.moveusedobject;
  190.       }
  191.    }
  192. }
  193. function loadbonuses()
  194. {
  195.    this.frm = Math.round(Math.random() * 7);
  196.    if(this.frm == 6 and Math.random() * 10 > 2)
  197.    {
  198.       this.frm = Math.round(Math.random() * 7);
  199.    }
  200.    if(this.frm == 0)
  201.    {
  202.       this.frm = 7;
  203.    }
  204.    this.gotoAndStop(this.frm);
  205.    xx = Math.round(Math.random() * 3);
  206.    if(xx == 0)
  207.    {
  208.       xx = 3;
  209.    }
  210.    this._x = 140 + 70 * xx;
  211.    this._y = -25 - Math.random() * 375 * 2;
  212.    this.onEnterFrame = this._parent.movebonuses;
  213.    this.onMouseDown = this._parent.onlinefire;
  214. }
  215. function movebonuses()
  216. {
  217.    if(_root._currentframe > 17 || _root._currentframe < 12)
  218.    {
  219.       removeMovieClip(this);
  220.    }
  221.    if(!pauseflag)
  222.    {
  223.       this._y += speed;
  224.       if(this._y > 380)
  225.       {
  226.          this.onLoad();
  227.       }
  228.       if(this.hitTest(car.hit))
  229.       {
  230.          switch(this._currentframe)
  231.          {
  232.             case 1:
  233.                score_get_Sound.start();
  234.                score += 10;
  235.                break;
  236.             case 2:
  237.                score_get_Sound.start();
  238.                score += 20;
  239.                break;
  240.             case 3:
  241.                score_get_Sound.start();
  242.                score += 50;
  243.                break;
  244.             case 4:
  245.                score_get_Sound.start();
  246.                score += 100;
  247.                break;
  248.             case 5:
  249.                bonus_get_Sound.start();
  250.                firecar = 120;
  251.                car.gun._visible = true;
  252.                car.onMouseDown = firecarfun;
  253.                break;
  254.             case 6:
  255.                score_get_Sound.start();
  256.                lives += 1;
  257.                break;
  258.             case 7:
  259.                bonus_get_Sound.start();
  260.                speedfast = 120;
  261.                car.turbo._visible = true;
  262.          }
  263.          this._y = 400;
  264.       }
  265.    }
  266. }
  267. function onlinefire()
  268. {
  269.    if(!pauseflag)
  270.    {
  271.       if(firecar > 0 && !fire && this._y > 0)
  272.       {
  273.          if(this._x > car._x - 20 && this._x < car._x + 20)
  274.          {
  275.             fire = true;
  276.             var _loc3_ = _root.getNextHighestDepth();
  277.             var _loc4_ = _root.attachMovie("expl","expl" + String(_loc3_),_loc3_,{_x:this._x,_y:this._y});
  278.             _loc4_.onEnterFrame = _root.moveobject;
  279.             this.onLoad();
  280.          }
  281.       }
  282.    }
  283. }
  284. function moveusedobject()
  285. {
  286.    if(_root._currentframe < 12)
  287.    {
  288.       removeMovieClip(this);
  289.    }
  290.    if(!pauseflag)
  291.    {
  292.       this._y += speed;
  293.       if(this._y > 380)
  294.       {
  295.          this.onLoad();
  296.       }
  297.    }
  298. }
  299. function moveobject()
  300. {
  301.    if(_root._currentframe < 12)
  302.    {
  303.       removeMovieClip(this);
  304.    }
  305.    if(!pauseflag)
  306.    {
  307.       this._y += speed;
  308.    }
  309. }
  310. frameN = 1;
  311. land.onEnterFrame = function()
  312. {
  313.    if(!pauseflag)
  314.    {
  315.       var _loc4_ = Math.round((315 - _root._ymouse) / 33 * 2);
  316.       if(_loc4_ > 10)
  317.       {
  318.          _loc4_ = 10;
  319.       }
  320.       if(_loc4_ < 0)
  321.       {
  322.          _loc4_ = 0;
  323.       }
  324.       var _loc3_ = 1.2;
  325.       if(car._x < 175)
  326.       {
  327.          _loc3_ = 0.9;
  328.       }
  329.       if(speedfast > 0)
  330.       {
  331.          speedfast -= 1;
  332.          _loc3_ = 1.5;
  333.          if(speedfast == 0)
  334.          {
  335.             car.turbo._visible = false;
  336.             bonus_lost_Sound.start();
  337.          }
  338.       }
  339.       if(speedlow > 0)
  340.       {
  341.          speedlow -= 1;
  342.          _loc3_ = 0.9;
  343.       }
  344.       if(speedverylow > 0)
  345.       {
  346.          speedverylow -= 1;
  347.          _loc3_ = 0.7;
  348.       }
  349.       if(stopdrive > 0)
  350.       {
  351.          stopdrive -= 1;
  352.          _loc3_ = 0.7;
  353.       }
  354.       speed = _loc4_ * _loc3_ * 1.5;
  355.       if(_root._currentframe > 14)
  356.       {
  357.          speed = 0;
  358.       }
  359.       _root.finishline._y += speed;
  360.       var _loc6_ = Math.abs(_root.finishline._y - 350) / (numlevel * 375 * countscr + 350);
  361.       _root.carsmall._y = 35 + 175 * _loc6_;
  362.       var _loc5_ = 13.5;
  363.       _root.pointer._rotation = speed * _loc5_;
  364.       if(this._y + speed < 320)
  365.       {
  366.          this._y += speed;
  367.       }
  368.       else
  369.       {
  370.          this._y += speed - 320;
  371.       }
  372.    }
  373.    if(playenergyflag)
  374.    {
  375.       playenergyflag = false;
  376.       engine_Sound.start();
  377.    }
  378.    if(_root._currentframe > 17 || _root._currentframe < 12)
  379.    {
  380.       playenergyflag = true;
  381.       engine_Sound.stop();
  382.       delete this.onEnterFrame;
  383.    }
  384. };
  385. engine_Sound.onSoundComplete = function()
  386. {
  387.    playenergyflag = true;
  388. };
  389. car.onEnterFrame = function()
  390. {
  391.    if(_root._currentframe > 17 || _root._currentframe < 12)
  392.    {
  393.       delete this.onEnterFrame;
  394.    }
  395.    if(_root._currentframe < 9 || _root._currentframe > 20)
  396.    {
  397.       removeMovieClip(this);
  398.    }
  399.    if(!pauseflag)
  400.    {
  401.       if(speed != 0)
  402.       {
  403.          var _loc3_ = 100 / speed;
  404.          dx = this._xmouse / _loc3_;
  405.       }
  406.       else
  407.       {
  408.          dx = 0;
  409.       }
  410.       if(undrive > 0)
  411.       {
  412.          undrive -= 1;
  413.          dx = Math.random() * 50 - 25;
  414.       }
  415.       if(firecar > 0)
  416.       {
  417.          firecar -= 1;
  418.          if(firecar == 0)
  419.          {
  420.             car.gun._visible = false;
  421.             bonus_lost_Sound.start();
  422.             delete this.onMouseDown;
  423.          }
  424.       }
  425.       if(this._x + dx < 365 && this._x + dx > 125)
  426.       {
  427.          this._x += dx;
  428.       }
  429.    }
  430. };
  431. bonuspanel.onEnterFrame = function()
  432. {
  433.    if(!pauseflag)
  434.    {
  435.       frm = 1;
  436.       if(firecar > 0)
  437.       {
  438.          if(stopdrive == 0 && speedfast == 0 || firecar < stopdrive && speedfast == 0 || stopdrive == 0 && firecar < speedfast)
  439.          {
  440.             frm = 2;
  441.          }
  442.       }
  443.       if(speedfast > 0)
  444.       {
  445.          if(firecar == 0 && stopdrive == 0 || speedfast < stopdrive && firecar == 0 || stopdrive == 0 && speedfast < firecar)
  446.          {
  447.             frm = 3;
  448.          }
  449.       }
  450.       if(stopdrive > 0)
  451.       {
  452.          if(firecar == 0 && speedfast == 0 || stopdrive < firecar && speedfast == 0 || firecar == 0 && stopdrive < speedfast)
  453.          {
  454.             frm = 4;
  455.          }
  456.       }
  457.       switch(frm)
  458.       {
  459.          case 1:
  460.             tx = 0;
  461.             break;
  462.          case 2:
  463.             tx = Math.floor(firecar / 12);
  464.             break;
  465.          case 3:
  466.             tx = Math.floor(speedfast / 12);
  467.             break;
  468.          case 4:
  469.             tx = Math.floor(stopdrive / 12);
  470.       }
  471.       if(frm != this._currentframe)
  472.       {
  473.          this.gotoAndStop(frm);
  474.          if(tx != 0)
  475.          {
  476.             bonustime = String(tx);
  477.          }
  478.          else
  479.          {
  480.             bonustime = "";
  481.          }
  482.       }
  483.       if(tx != 0 && frameN % 12 == 0)
  484.       {
  485.          bonustime = String(tx);
  486.       }
  487.       if(_root._currentframe > 14 || _root._currentframe < 12)
  488.       {
  489.          stopdrive = 0;
  490.          firecar = 0;
  491.          speedfast = 0;
  492.          speedlow = 0;
  493.          speedverylow = 0;
  494.          undrive = 0;
  495.          this.gotoAndStop(1);
  496.          bonustime = "";
  497.          car.turbo._visible = false;
  498.          car.gun._visible = false;
  499.          delete this.onEnterFrame;
  500.       }
  501.    }
  502. };
  503. bonuses.onLoad = function()
  504. {
  505.    var _loc4_ = 2;
  506.    var _loc2_ = 0;
  507.    while(_loc2_ < _loc4_)
  508.    {
  509.       var _loc3_ = bonuses.duplicateMovieClip("bonuses" + String(_loc2_),200 + _loc2_);
  510.       _loc3_.onLoad = this._parent.loadbonuses;
  511.       _loc2_ = _loc2_ + 1;
  512.    }
  513. };
  514. obstacles.onLoad = function()
  515. {
  516.    if(numlevel % 3 != 0)
  517.    {
  518.       var _loc4_ = numlevel + 1;
  519.       if(numlevel > 5)
  520.       {
  521.          _loc4_ = 6;
  522.       }
  523.       var _loc2_ = 0;
  524.       while(_loc2_ < _loc4_)
  525.       {
  526.          var _loc3_ = obstacles.duplicateMovieClip("obstacles" + String(_loc2_),100 + _loc2_);
  527.          _loc3_.onLoad = this._parent.loadobstacles;
  528.          _loc2_ = _loc2_ + 1;
  529.       }
  530.    }
  531. };
  532. cars.onLoad = function()
  533. {
  534.    if(numlevel % 3 == 0)
  535.    {
  536.       var _loc4_ = 3;
  537.       var _loc2_ = 0;
  538.       while(_loc2_ < _loc4_)
  539.       {
  540.          var _loc3_ = cars.duplicateMovieClip("cars" + String(_loc2_),300 + _loc2_);
  541.          _loc3_.onLoad = this._parent.loadcars;
  542.          _loc2_ = _loc2_ + 1;
  543.       }
  544.    }
  545. };
  546.